import java.util.HashSet;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: mirac
 * Date: 2025-09-08
 * Time: 20:57
 */
public class Solution {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String a = in.nextLine();  //应该输入的
            String b = in.nextLine();  //实际输入的
            a = a.toUpperCase();
            b = b.toUpperCase();
            //把实际输入的字符放进集合
            HashSet<Character> set = new HashSet<>();
            for (int i = 0; i < b.length(); i++) {
                if (!set.contains(b.charAt(i))) {
                    set.add(b.charAt(i));
                }
            }
            //将应该输入的与这个集合的字符进行比较
            HashSet<Character> set1 = new HashSet<>();
            for (int i = 0; i < a.length(); i++) {
                if (!set.contains(a.charAt(i)) && !set1.contains(a.charAt(i))) {
                    System.out.print(a.charAt(i));
                    set1.add(a.charAt(i));
                }
            }
        }
    }
}
